<%@tag pageEncoding="UTF-8"%>
<%@attribute name="list" type="java.util.Collection" required="true" description="属性列表" %>
<%@attribute name="name" type="String" required="true" description="radio的name属性，必须"%>
<%@attribute name="require" type="Boolean"  description="是否是必填字段,默认选中第一个"%>
<%@attribute name="id" type="String" description="radio 的ul,可选"%>
<%@attribute name="clazz" type="String" description="radio ul标签的 class属性"%>
<%@attribute name="selected" type="String" description="被选中的单选框"%>
<%@attribute name="labelAttr" type="String" description="标签属性名"%>
<%@attribute name="valueAttr" type="String" description="值属性名"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="idStr" value=""/>
<c:if test="${not empty id }">
<c:set var="idStr" value="id='${id }'"/>
</c:if>
<c:if test="${empty require}">
    <c:set var="require" value="true"/>
</c:if>
<c:if test="${empty labelAttr }">
    <c:set var="labelAttr" value="label"/>
    <c:set var="valueAttr" value="value"/>
</c:if>
<c:forEach items="${list}" var="each" varStatus="var">
    <label class="${empty clazz ? 'checkbox-inline' : clazz}">
        <input type="radio" name='${name }' class="ace" ${(selected eq each[valueAttr]) or (empty selected and require and var.index eq 0) ? 'checked="checked"':'' }  value="${each[valueAttr] }">
        <span class="lbl"> ${each[labelAttr]}</span>
    </label>
</c:forEach>